package com.jason.learn.springcloud.orderservice.controler;

import com.jason.learn.springcloud.orderservice.enty.BuyOrder;
import com.jason.learn.springcloud.orderservice.maper.OrderMapper;
import com.jason.learn.springcloud.orderservice.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
@RequestMapping("/buyOrder")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private OrderMapper orderMapper;

    @RequestMapping("/createBuyOrder")
    public Long createBuyOrder(Long merNo, BigDecimal amount,String buyerCard){
        return orderService.createOrder(merNo,amount,buyerCard);
    }

    @RequestMapping("/payOrder")
    public boolean payOrder(Long orderId,Long inAccountId){
        return orderService.orderPayFlow(orderId,inAccountId);
    }

    @RequestMapping("/queryOrderById")
    public BuyOrder queryOrderById(Long orderId){
        return orderMapper.findById(orderId);
    }
}
